<?php

/**************************************************************+
| osBulletin - A powerful open source forum software package.  |
---------------------------------------------------------------+
| Released under the terms & conditions of v2 of the           |
| GNU General Public License. For details refer to             |
| the included gpl.txt file or visit http://gnu.org.           |
***************************************************************/

require_once(MAIN_DIR.'/includes/config.php');
require_once(MAIN_DIR.'/includes/class_core.php');

// osB = core class in class_core.php 

class osB_DB
{

// $this->query - Interface for MySQL functions.
public $query;

  public function __construct()
  {
	$this->db = $config['db'];
	$this->user = $config['username'];
    $this->password = $config['password'];
	$this->host = $config['host'];
  }
  
  public function init_db()
  {
	$this->connect = @mysql_connect($this->host, $this->user, $this->password);
	if(!$this->connect)
	{
	  parse_error_f("MySQL", "There has been a database error.  osBulletin could not connect to the MySQL server."); // parse_error_f($type, $message) -- class_core.php function
    }
    
    $this->select_db = @mysql_select_db($this->db);
    if(!$this->select_db)
	{
	  parse_error_f("MySQL", "There has been a database error.  osBulletin could not connect to the MySQL database.");
    }

  }
  
  // Based on FlexBB's (http://www.flexbb.net) MySQL function system.  FlexBB is licensed under the GNU GPL, just like osBulletin.
  public function query($qry)
  {
	if(!$this->query = @mysql_query($qry))
	{
	  parse_error_f("MySQL", "There has been a database error.  osBulletin could not perform a query successfully.");
    }
    
    if($this->query)
    {

	  return $this->query;

    } else {

	  return false;

    }
  }
  
  public function fetch_array($qry)
  {
	if($result = @mysql_fetch_array($qry)) {

      return $result;
      
    } else {

	  return false;
	  
    }
  }
  
  public function num_rows($qry)
  {
	if($result = @mysql_num_rows($qry)) {

	  return $result;
	  
    } else {

	  return false;
	  
    }
  }

}

?>
